import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
// import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
// import Components from 'unplugin-vue-components/vite';
// import { VantResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    // 开发阶段启用源码映射：https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
    sourcemap: process.env.NODE_ENV === 'development',
  },

  resolve: {
    alias: {
      '@': '/src',
    },
  },
  plugins: [
    uni(),
    // vue(),
    //自动引入
    AutoImport({
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
      ],
      imports: ['vue', 'uni-app'],
      dts: 'src/types/auto-import.d.ts',
    }),
    // Components({
    //   resolvers: [VantResolver()],
    // }),
  ],
  server: {
    port: 3001,
    proxy: {
      '/shui': {
        target: 'http://192.168.120.254:2001',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/shui/, ''),
      },
    },
  },
})
